package com.example.chinawenddingexpo.repository;

import com.example.chinawenddingexpo.model.WeddingService;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

@Repository
public interface WeddingServiceRepository extends JpaRepository<WeddingService, Long> {
    
    List<WeddingService> findByUserIdOrderByServiceDateDesc(Long userId);
    
    List<WeddingService> findByUserIdAndStatusOrderByServiceDateDesc(Long userId, WeddingService.BookingStatus status);
    
    List<WeddingService> findByExhibitorIdAndServiceDateBetweenOrderByServiceDateAsc(
            Long exhibitorId, LocalDate startDate, LocalDate endDate);
    
    @Query("SELECT ws FROM WeddingService ws WHERE ws.user.id = :userId AND ws.serviceDate >= :today ORDER BY ws.serviceDate ASC")
    List<WeddingService> findUpcomingServices(@Param("userId") Long userId, @Param("today") LocalDate today);
    
    List<WeddingService> findByServiceTypeAndStatusOrderByServiceDateDesc(
            WeddingService.ServiceType serviceType, WeddingService.BookingStatus status);
}